SWEP.Author="AlexPowell"
SWEP.Instructions=""
SWEP.Contact=""
SWEP.Purpose=""

SWEP.ViewModelFOV=62
SWEP.ViewModelFlip=false
SWEP.AnimPrefix	="rpg"

SWEP.Spawnable=false
SWEP.AdminSpawnable=true
SWEP.Primary.ClipSize=-1
SWEP.Primary.DefaultClip=0
SWEP.Primary.Automatic=false
SWEP.Primary.Ammo=""

SWEP.Secondary.ClipSize=-1
SWEP.Secondary.DefaultClip=0
SWEP.Secondary.Automatic=false
SWEP.Secondary.Ammo=""

local LockSound=Sound("doors/door_latch3.wav")
function SWEP:Initialize()
	self:SetWeaponHoldType("normal")
end

function SWEP:Deploy()
	if SERVER then
		self.Owner:DrawViewModel(false)
		self.Owner:DrawWorldModel(false)
	end
end

function SWEP:PrimaryAttack()
	local tr=self.Owner:GetEyeTraceNoCursor()
	if tr.Entity:GetClass()=="prop_door_rotating" and doors[tr.Entity:EntIndex()]==self.Owner:UniqueID() and self.Owner:EyePos():Distance(tr.Entity:GetPos())<65 then
		if SERVER then
			tr.Entity:Fire("lock","",0)
			self.Owner:EmitSound(LockSound,100,100)
		end
		return
	else
		return
	end
end
function SWEP:SecondaryAttack()
	local tr=self.Owner:GetEyeTrace()
	if tr.Entity:GetClass()=="prop_door_rotating" and doors[tr.Entity:EntIndex()]==self.Owner:UniqueID() and self.Owner:EyePos():Distance(tr.Entity:GetPos())<65 then
		if SERVER then
			tr.Entity:Fire("unlock","",0)
			self.Owner:EmitSound(LockSound,100,100)
		end
		return
	else
		return
	end
end